include ../ffox.mk

# **********************************************************************************************
#                            FLASH PROGRAMMING                                         
#
# Alternate make target for flash programming only
#
# You must create a special Eclipse make target (program) to run this part of the makefile 
# (Project -> Create Make Target...  then set the Target Name and Make Target to "program")
#
# OpenOCD is run in "batch" mode with a special configuration file and a script file containing
# the flash commands. When flash programming completes, OpenOCD terminates.
#
# Note that the script file of flash commands (script.ocd) is part of the project
#
# Programmers: Martin Thomas, Joseph M Dupre, James P Lynch
# **********************************************************************************************

# specify the directory where openocd executable and configuration files reside
OPENOCD_DIR = 'c:/Program Files/openocd-2007re204/bin/'

# specify OpenOCD executable (pp is for the wiggler, ftd2xx is for the USB debuggers)
#OPENOCD = $(OPENOCD_DIR)openocd-pp.exe
OPENOCD = $(OPENOCD_DIR)openocd.exe

# specify OpenOCD configuration file (pick the one for your device)
#OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-wiggler-flash-program.cfg
#OPENOCD_CFG = $(OPENOCD_DIR)at91sam7s256-jtagkey-flash-program.cfg
OPENOCD_CFG_PROGRAM = $(OPENOCD_DIR)at91sam7s256-armusbocd-flash-program.cfg
OPENOCD_CFG_DEBUG = $(OPENOCD_DIR)at91sam7s256-armusbocd.cfg

# program the AT91SAM7S256 internal flash memory
program:
	@echo "Flash Programming with OpenOCD..."			# display a message on the console
	$(OPENOCD) -f $(OPENOCD_CFG_PROGRAM)				# program the onchip FLASH here
	@echo "Flash Programming Finished."				# display a message on the console

# run OpenOCD in debugging mode
openocd:
	$(OPENOCD) -f $(OPENOCD_CFG_DEBUG)

# debug the program
debug:
	@echo "Do 'make openocd' in another shell if you can't connect to your program"
	@echo ""
	$(DEBUG) ../sys/$(NAME).out

clean:

